const router = require('koa-router')({prefix: '/user'});
const controller = require('controller/user.js');

/**
 * @api {post} /user/login PC端登录
 * @apiVersion 1.0.0
 * @apiName login
 * @apiGroup 用户模块
 * @apiParam (请求参数) {String} username 账号
 * @apiParam (请求参数) {String} password 密码
 * @apiSampleRequest /user/login
 * @apiSuccessExample {json} 请求成功：
 * {
			"headers": {
				"code": 0,
				"message": "欢迎进入"
			},
			"data": {
				"uuid": "002",
				"username": "chen",
				"nickname": "苏家姑娘",
				"avatar": "/avatar/22.png",
				"gender": 2,
				"note": "-",
				"role": 0,
				"status": 1,
				"lastTime": "2023-06-28 09:05:46",
				"createTime": "2023-06-15 15:00:00",
				"updateTime": "2023-06-28 09:05:46",
				"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNoZW4iLCJpYXQiOjE2ODc5NTA3NzksImV4cCI6MTY4Nzk4Njc3OX0.KSHvjsWjPy3_AGidLpCoPPR2f9S9U_YRCkygfDEG-4k"
			}
		}
 */
router.post('/login', controller.login);

/**
 * @api {get} /user/info 获取用户信息
 * @apiVersion 1.0.0
 * @apiName info
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiParam (query) {String} [author] 作者
 * @apiParam (query) {String} [keywrod] 标题搜索
 * @apiSampleRequest /user/info
 * @apiSuccessExample {json} 请求成功：
 * {
			"headers": {
				"code": 0,
				"message": "success"
			},
			"data": {
				"uuid": "002",
				"username": "chen",
				"nickname": "苏家姑娘",
				"avatar": "/avatar/22.png",
				"gender": 2,
				"note": "-",
				"role": 0,
				"status": 1,
				"lastTime": "2023-06-29 08:53:03",
				"createTime": "2023-06-15 15:00:00",
				"updateTime": "2023-06-29 08:53:03",
				"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNoZW4iLCJpYXQiOjE2ODc5OTk5ODMsImV4cCI6MTY4ODAzNTk4M30.6kiFu0nTg_Yrf5tXnNua4ucNf_pS8TGXoI6ni0CqHBg"
			}
		}
 */
router.get('/info', controller.info);

/**
 * @api {post} /user/logout 退出
 * @apiVersion 1.0.0
 * @apiName logout
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/logout
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.post('/logout', controller.logout);

/**
 * @api {get} /user/list 用户列表
 * @apiVersion 1.0.0
 * @apiName list
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/list
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.get('/list', controller.list);

/**
 * @api {post} /user/add 添加用户
 * @apiVersion 1.0.0
 * @apiName add
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/add
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.post('/add', controller.add);

/**
 * @api {post} /user/edit 编辑用户
 * @apiVersion 1.0.0
 * @apiName edit
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/edit
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.post('/edit', controller.edit);

/**
 * @api {delete} /user/delete 删除用户
 * @apiVersion 1.0.0
 * @apiName delete
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/delete
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.delete('/delete', controller.delete);

/**
 * @api {get} /user/easyList 简易查询全部用户
 * @apiVersion 1.0.0
 * @apiName easyList
 * @apiGroup 用户模块
 * @apiHeader {String} Authorization 用户授权token
 * @apiSampleRequest /user/easyList
 * @apiSuccessExample {json} 请求成功：
 * {}
 */
router.get('/easyList', controller.easyList);

module.exports = router;
